app.controller('selfController', ['$scope', 'httpWrapService', '$stateParams',
    'AlertFactory', 'CropImgFactory',
    function ($scope, httpWrapService, $stateParams, AlertFactory, CropImgFactory) {
        $scope.entity = {};
        $scope.Alert = AlertFactory.newInstance();

        $scope.setImg = function (img) {
            $scope.entity.picture = img;
        }
        $scope.CropImg = CropImgFactory.newInstance($scope.setImg);

        httpWrapService.post('system/self/view.do').then(function (res) {
            $scope.entity = res.data.entity;
        });

        $scope.save = function () {
            httpWrapService.defaultSave('system/self/update.do', {
                entity: $scope.entity
            }, $scope).then(function (res) {
                $scope.Alert.addSuccess('保存成功');
            });

            // 保存成功返回列表页面

        }
    }]);
